package com.rz.htk.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rz.htk.sys.entity.StateCode;
import com.rz.htk.sys.mapper.StateCodeMapper;
import com.rz.htk.sys.service.IStateCodeService;
import org.springframework.stereotype.Service;

/**
 * @ClassName StateCodeServiceImpl
 * @Description 省/州信息
 * @Author maweiyue
 * @Date 2019/8/16 11:37
 */
@Service
public class StateCodeServiceImpl extends ServiceImpl<StateCodeMapper, StateCode> implements IStateCodeService {


    /**
     * 根据省/州名称获取详细信息
     * @param name 省州名称（全称）
     * @param country 国家2字节简码
     * @return
     */
    public StateCode getByName(String name, String country){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("country", country);
        queryWrapper.eq("state_full", name.replaceAll(" ", "").toLowerCase());
        StateCode stateCode = getOne(queryWrapper);
        return stateCode;
    }
}
